

using System;
using System.Collections;
using System.Diagnostics;


using CStock;



namespace CStock
{
	/// <summary>
	/// Summary description for DataClasses.
	/// </summary>
	public class DataClasses : ArrayList, IDataClasses
	{
		#region Constructor
		public DataClasses()
		{
		}
		#endregion


        //}

		#region IDataClasses

		/// <summary>
		/// 
		/// </summary>
		public IDataClass this[string myID]
		{
			get
			{
				for(int i = 0; i < this.Count; i ++)
				{
					IDataClass myPf = this[i]  as IDataClass;
					//if( myPf.ID == name)
                    if (myPf.ID == myID)
					{
						return myPf;
					}
				}
				return null;
			}
		}
		public new IDataClass this[int index]
		{
			get
			{
				try
				{
					if ((index >= 0) && (index < base.Count))
					{
						object o = base[index];
						return o as IDataClass;
					}
					else
					{
						return null;
					}
				}
				catch
				{
					Debug.Assert(false,"error getting IDataClass");
					return null;
				}
			}
			set
			{
				if ((index >= 0) && (index < base.Count))
				{
					base[index] = value;
				}
			}
		}

		public override int Add(object obj)
		{
			try
			{
				DataClass objDataClass = (DataClass)obj;
				if (this.Count == 0)
				{
					//Empty Collection -> First Element
					base.Add(objDataClass);
					return 0;
				}
				else
				{
					base.Add(objDataClass);
					return 0;
				}
			}
			catch (Exception exc)
			{
				throw exc;
			}
			
		}
		public override void Remove(object obj)
		{
			DataClass objDataClass=(DataClass)obj;
			if (this.Contains(objDataClass))
			{
				base.Remove(objDataClass);
			}
		}

	
		#endregion
	}
}
